﻿Imports System.IO
Imports SearchOption = Microsoft.VisualBasic.FileIO.SearchOption


Public Class Compresor
    Inherits ProcesadorComun

    Private _parametro As String
    Public Event Verbose(ByVal mensaje As String)


    Public WriteOnly Property Parametro As String
        Set(value As String)
            _parametro = value
        End Set
    End Property

    Public Sub Comprime(ByVal directorio As String)

        Dim inStartInfo As New ProcessStartInfo
        inStartInfo.WindowStyle = ProcessWindowStyle.Normal
        inStartInfo.FileName = "cmd.exe"

        RaiseEvent Verbose(String.Format("Comprimiendo ""{0}"".", AlinearIzquierda(directorio, 70)))

        inStartInfo.Arguments = "/C """"" & Ejecutable & """" & " a -m5 ""C:\input\descarga.rar"" """ & directorio & """"""
        Process.Start(inStartInfo).WaitForExit()
    End Sub

    Public Sub New(ByVal nombre As String, ByVal ejecutable As String, ByVal path() As String)
        If BuscaEjecutable(path, ejecutable) Then
            RaiseEvent Verbose("Procesador """ & ejecutable & """ vinculado!")
            Me.Nombre = nombre
        End If
    End Sub

End Class
